var hue;
var picker;
//var gLogger;
var dd1, dd2;
var r, g, b;

function init() {
if (typeof(ygLogger) != &quot;undefined&quot;)
ygLogger.init(document.getElementById(&quot;logDiv&quot;));
pickerInit();
//ddcolorposter.fillcolorbox(&quot;colorfield1&quot;, &quot;colorbox1&quot;) //PREFILL &quot;colorbox1&quot; with hex value from &quot;colorfield1&quot;
//ddcolorposter.fillcolorbox(&quot;colorfield2&quot;, &quot;colorbox2&quot;) //PREFILL &quot;colorbox1&quot; with hex value from &quot;colorfield1&quot;
}

// Picker ---------------------------------------------------------

function pickerInit() {
hue = YAHOO.widget.Slider.getVertSlider(&quot;hueBg&quot;, &quot;hueThumb&quot;, 0, 180);
hue.onChange = function(newVal) { hueUpdate(newVal); };

picker = YAHOO.widget.Slider.getSliderRegion(&quot;pickerDiv&quot;, &quot;selector&quot;, 0, 180, 0, 180);
picker.onChange = function(newX, newY) { pickerUpdate(newX, newY); };

hueUpdate();

dd1 = new YAHOO.util.DD(&quot;pickerPanel&quot;);
dd1.setHandleElId(&quot;pickerHandle&quot;);
dd1.endDrag = function(e) {
// picker.thumb.resetConstraints();
// hue.thumb.resetConstraints();
};
}

executeonload(init);

function pickerUpdate(newX, newY) {
pickerSwatchUpdate();
}


function hueUpdate(newVal) {

var h = (180 - hue.getValue()) / 180;
if (h == 1) { h = 0; }

var a = YAHOO.util.Color.hsv2rgb( h, 1, 1);

document.getElementById(&quot;pickerDiv&quot;).style.backgroundColor =
&quot;rgb(&quot; + a[0] + &quot;, &quot; + a[1] + &quot;, &quot; + a[2] + &quot;)&quot;;

pickerSwatchUpdate();
}

function pickerSwatchUpdate() {
var h = (180 - hue.getValue());
if (h == 180) { h = 0; }
document.getElementById(&quot;pickerhval&quot;).value = (h*2);

h = h / 180;

var s = picker.getXValue() / 180;
document.getElementById(&quot;pickersval&quot;).value = Math.round(s * 100);

var v = (180 - picker.getYValue()) / 180;
document.getElementById(&quot;pickervval&quot;).value = Math.round(v * 100);

var a = YAHOO.util.Color.hsv2rgb( h, s, v );

document.getElementById(&quot;pickerSwatch&quot;).style.backgroundColor =
&quot;rgb(&quot; + a[0] + &quot;, &quot; + a[1] + &quot;, &quot; + a[2] + &quot;)&quot;;

document.getElementById(&quot;pickerrval&quot;).value = a[0];
document.getElementById(&quot;pickergval&quot;).value = a[1];
document.getElementById(&quot;pickerbval&quot;).value = a[2];
var hexvalue = document.getElementById(&quot;pickerhexval&quot;).value =&#39;#&#39;+
YAHOO.util.Color.rgb2hex(a[0], a[1], a[2]);
ddcolorposter.initialize(a[0], a[1], a[2], hexvalue)
if (hexvalue!=&quot;#FFFFFF&quot;) document.getElementById(&quot;pickerhexval&quot;).select();
}